package A14;

public class OrderDetail {
    private int quantity; // 商品数量
    private Product product; // 关联：1个商品项

    public OrderDetail(int quantity, Product product) {
        this.quantity = quantity;
        this.product = product;
    }

    // 计算小计（商品单价 * 数量）
    public double calculateSubTotal() {
        return product.getPriceForQuantity(quantity);
    }

    // 计算总重量（商品重量 * 数量）
    public double calculateWeight() {
        return product.getWeight() * quantity;
    }

    // getter/setter
    public int getQuantity() {
        return quantity;
    }

    public Product getProduct() {
        return product;
    }
}